﻿@model PagedList<AddTempProductModel>
@{
    ViewBag.Title = "入库物流列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    TempProductQueryModel paramModel = new TempProductQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (TempProductQueryModel)ViewBag.paramModel;
    }
    Dictionary<string, string> dc = new Dictionary<string, string>();
    Dictionary<string, string> labelDicTypeName  = ReleaseBiz.GetLabelTypeNameDic();
}
<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("tempProductlist", "TempProduct")" method="get">
    <div class="form_query">
        <div>
            料号：
            <input type="text" name="MPN" id="MPN" class="abc input-default" placeholder="" value="@paramModel.MPN">&nbsp;
        </div><div>
            板块：
            <select id="label_type" name="label_type">
                <option value="-10" @(paramModel.label_type == -10 ? "selected" : "")>全部板块</option>
                @{
                    dc = labelDicTypeName;
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.label_type.ToString());
            </select>&nbsp;
        </div><div>
            上传结果：
            <select id="up_status" name="up_status">
                <option value="-10" @(paramModel.up_status == -10 ? "selected" : "")>全部结果</option>
                <option value="1" @(paramModel.up_status == 1 ? "selected" : "")>成功</option>
                <option value="0" @(paramModel.up_status == 0 ? "selected" : "")>失败</option>
            </select>&nbsp;
        </div><div>
            上传时间：
            <input type="text" name="begTime" class="calendar calendar-time" id="begTime" value="@paramModel.begTime.ToString(1)"> - <input type="text" name="endTime" class="calendar calendar-time" id="endTime" value="@paramModel.endTime.ToString(1)">&nbsp;
        </div><div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp; <button type="button" class="btn btn-success" id="additem">添加单个物料</button>
            &nbsp;&nbsp; <button type="button" class="btn btn-success" id="additemMore" onclick="document.location='addMoreTempProduct'">批量上传</button>
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th style="width:40px"><input type="checkbox" name="chkall" id="chkall" />全选</th>
            <th style="width:65px">图片</th>
            <th>料号</th>
            <th>品牌</th>
            <th>分类</th>
            <th>供应商</th>
            <th>物料来源</th>
            <th>板块</th>
            <th>业务编号</th>
            <th>普通会员可看</th>
            <th>单位</th>
            <th>DC号</th>
            <th>库存数量</th>
            <th>最小订购量</th>
            <th>上传价格</th>
            <th>币种</th>
            <th>供货价</th>
            <th>市场价</th>
            <th>是否含税</th>
            <th>上传结果</th>
            <th>上传时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
<tr class="@HtmlPagerHelper.TrClass(index)">
    <td>
        <input type="checkbox" name="cbx_last" value="@m.aDZ_GoodsTemp.seq_id" />@m.aDZ_GoodsTemp.seq_id
    </td>
    <td style="padding:5px 0 0 2px;">
        @{
            foreach (var item in m.aDZ_GoodsIMGs.OrderBy(t => t.sort_NO))
            {
                <a class="list-img" href="@ImageFileBiz.GetImg(item.img_url)" target="_blank"> <img style="width:30px;margin:1px 1px 1px 1px;" src="@ImageFileBiz.GetImg(item.img_url,"small")" /></a>
            }
        }
    </td>
    <td>@m.aDZ_GoodsMaster.MPN</td>
    <td>@m.aDZ_BrandMaster.brand_name</td>
    <td>@m.aDZ_GoodsCategory.category_name</td>
    <td>@m.aDZ_SupplierMaster.supplier_name</td>
    <td>@m.aDZ_MaterialSource.supplier_name</td>
    <td>
        <div class="">@labelDicTypeName[m.aDZ_GoodsLabel.label_type.ToString()]</div>
    </td>
    <td>
        @m.goodsBusinessModel.business_id
    </td>
    <td>
        @if (m.aDZ_GoodsLabel.label_type == 1 || m.aDZ_GoodsLabel.label_type > 5)
        {
            if (m.aDZ_GoodsLabel.show_min_level == 0)
            {
                @:<div class="green">可看</div>
            }
            else
            {
                @:<div class="red">不可看</div>
            }
        }
        else
        {
            <label>--</label>
        }
    </td>
    <td>@m.aDZ_GoodsMaster.goods_unit</td>
    <td>@m.aDZ_GoodsMaster.DCN</td>
    <td>@m.aDZ_GoodsMaster.stock_amount</td>
    <td>@m.aDZ_GoodsMaster.min_amount</td>
    <td>@m.aDZ_GoodsMaster.price</td>
    <td>
        @switch (m.aDZ_GoodsMaster.currency_type)
        {
            case 0:
                @:<div class="">人民币</div>
                break;
            case 1:
                @:<div class="red">美金</div>
                break;
        }
    </td>
    <td>@m.aDZ_GoodsMaster.supply_price</td>
    <td>@m.aDZ_GoodsMaster.market_price</td>
    <td>
        @switch (m.aDZ_GoodsMaster.include_tax)
        {
            case 0:
                @:<div class="">未含税</div>
                break;
            case 1:
                @:<div class="green">含税</div>
                break;
        }
    </td>

    <td>
        @switch (m.aDZ_GoodsTemp.status)
        {
            case 1:
            case 2:
                @:<div class="green">上传成功</div>
                break;
            case 0:
                @:<div class="red">上传失败</div>
                break;
        }
    </td>
    <td>@m.aDZ_GoodsTemp.create_time.ToString(1)</td>

    <td>
        <a href="@Url.Action("addTempProduct", "TempProduct", new { id = m.aDZ_GoodsTemp.seq_id})">编辑</a>
        <a href="javascript:void(0);" onclick="deleteTemp(@m.aDZ_GoodsTemp.seq_id)">删除</a>


        <a href="javascript:void(0);" onclick="toWithdraw(@m.aDZ_GoodsTemp.seq_id)">上架</a>
    </td>
</tr>
                        }
                        <tr>
                            <td colspan="20">
                                <a href="javascript:void(0);" onclick="toWithdrawMore()">上架选择项</a>
                                <a href="javascript:void(0);" onclick="deleteTempMore()">删除选择项</a>
                            </td>
                        </tr>
                        }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    reloadHandler = function ()
    {
        window.location.reload();
    }
    function toWithdraw(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将该物料上架吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("toWithdraw", "TempProduct")";
                      parameter = { id: id };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
              {
                  text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
    }
    function toWithdrawMore(id) {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要上架的数据", 'warning');
            return;
        } 

        BUI.Message.Show({
            title: '提示',
            msg: '确定要将选择的物料都上架吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("toWithdrawMore", "TempProduct")";
                      parameter = { ids: ids };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
              {
                  text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
    }

    function deleteTemp(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要删除该记录吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("delete", "TempProduct")";
                      parameter = { id: id };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
              {
                  text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
    }
    function deleteTempMore(id) {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要删除的数据", 'warning');
            return;
        }

        BUI.Message.Show({
            title: '提示',
            msg: '确定要删除选择的记录吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("deleteMore", "TempProduct")";
                      parameter = { ids: ids };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
              {
                  text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
    }

    $(function () {
        $('#additem').on('click', function () {
            window.document.location.href = "@Url.Action("addTempProduct", "TempProduct")";
        });

    });

</script>